package com.winter.controller;

import com.winter.model.Admin;
import com.winter.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@RequestMapping("/admin")
@Controller
public class AdminController {
    @Autowired
    private AdminService adminService;

    //登录
    @RequestMapping("/login")
    public String login(Admin admin){
        List<Admin> admin1 = adminService.selectAdmin(admin.getName());
        for(Admin admin2 :admin1){
            if(admin2.getPassword().equals(admin.getPassword())){
                return "redirect:/index.jsp";
            }
            else{
                return "login";
            }
        }
        return "404";
    }
}
